package com.lucenewapper.beans;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.lucenewapper.search.Searchable;

public class UserSearchable extends User implements Searchable {

	public static UserSearchable create(long id) {
		UserSearchable s = new UserSearchable();
		s.setId(id);
		s.setName("name" + id);
		return s;
	}

	@Override
	public int compareTo(Searchable o) {
		return (int) (getId() - o.id());
	}

	@Override
	public long id() {
		return getId();
	}

	@Override
	public java.util.List<String> storeFields() {
		return Arrays.asList("id");
	}

	@Override
	public java.util.List<String> indexFields() {
		return Arrays.asList("name");
	}

	@Override
	public float boost() {
		return 0;
	}

	public Map<String, String> extendStoreDatas() {
		Map<String, String> ei = new HashMap<>();
		ei.put("type", "乱七八糟");
		return ei;
	}

	public Map<String, String> extendIndexDatas() {
		Map<String, String> ei = new HashMap<>();
		ei.put("type", "乱七八糟");
		return ei;
	}

	@Override
	public List<? extends Searchable> ListPage(int page, int pageSize) {
		return null;
	}

	@Override
	public List<? extends Searchable> ListAfter(long id, int count) {
		List<UserSearchable> datas = new ArrayList<>();
		if (id > 1000) {
			return datas;
		}
		long startId = id + 1;
		for (int i = 0; i < count; i++) {
			datas.add(UserSearchable.create(startId));
			startId++;
		}
		return datas;
	}
}
